package com.cnswhy.cloud.server.core.service.impl;


import com.cnswhy.cloud.common.core.base.service.SuperServiceImpl;
import com.cnswhy.cloud.common.redis.service.RedisService;
import com.cnswhy.cloud.server.core.constant.RedisConstant;
import com.cnswhy.cloud.server.core.dao.SysConfigMapper;
import com.cnswhy.cloud.server.core.entity.SysConfig;
import com.cnswhy.cloud.server.core.service.SysConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import java.util.List;

/**
 * <p>
 * 业务实现类
 * 系统配置表
 * </p>
 *
 * @author cnswhy
 * @date 2020-10-16
 */
@Slf4j
@Service

public class SysConfigServiceImpl extends SuperServiceImpl<SysConfigMapper, SysConfig> implements SysConfigService {
    @Autowired
    RedisService redisService;
    //@PostConstruct
    public void init(){
        List<SysConfig> configList = list();
        if(configList != null && configList.size() > 0 )
        {
            for (SysConfig sysConfig : configList)
            {
                redisService.hset(RedisConstant.SYS_CONFIG+sysConfig.getType(), sysConfig.getConfigKey(), sysConfig.getConfigValue());
            }
        }
    }


}
